<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        console.log('开始')

        var balance = 1000;
        var year = 0
        while (balance <= 5000){
            balance *= 1.05;
            year++
            console.log(balance);
        }
        console.log('存够5000需要' + year + '年');


    </script>
</head>
<body>

</body>
</html>